from itsdangerous import TimedJSONWebSignatureSerializer as Serializer
from meiduo_mall_1 import settings

def generic_openid(openid):
    s=Serializer(secret_key=setattr.SECRET_KEY,expires_in=3600)
    access_token = s.dumps({'openid':openid})

    #讲byeS类型装换
    return access_token.decode()


def check_access_token(token):
    s = Serializer(secret_key=settings.SECRET_KEY, expires_in=3600)
    try:
        result=s.loads(token)
    except Exception:
        return None
    else:
        return result.get('openid')

